import Mock from 'mockjs';
import { user_menus } from '../mock-data/data-menu';

Mock.mock('/museum-role/user/loginById', 'post', options => {
  const { username, password } = JSON.parse(options.body);
  let code = 500;
  if (username === 'mock' && password === '123') {
    code = 200;
  }
  return {
    code: code,
    message: '用户名mock, 密码123',
    data: {
      userInfo: {
        userId: 10,
        areaNumber: 113
      },
      token: 'login-test-token'
    }
  };
});

Mock.mock('/museum-role/user/getUserInfo', 'get', {
  code: 200,
  message: '获取用户信息',
  data: {
    userMessage: {
      userId: 10,
      userName: 'mock',
      userStatus: 0,
      userPassword: 'mock',
      userPhone: '13603527760',
      userEmail: '13603527760',
      userWork: '开发人',
      realName: '省级人员',
      userSex: '男',
      userDesc: '但行好事,莫问前程',
      areaName: 'mock县'
    }
  }
});

Mock.mock('/museum-role/user/getMenu', 'get', {
  code: 200,
  message: '获取用户菜单',
  data: {
    menus: user_menus
    // menus: []
    // 超管系统管理菜单
    // menus: [
    //   {
    //     permissionId: 1,
    //     parentId: 0,
    //     name: '超管-系统管理',
    //     path: '/super',
    //     redirect: '/super/user',
    //     component: 'Layout',
    //     status: 0,
    //     meta: {
    //       icon: 'el-icon-setting',
    //       title: '超管-系统管理'
    //     },
    //     createTime: '2020-12-08 21:25:45',
    //     updateTime: '2020-12-08 21:25:45',
    //     children: [
    //       {
    //         permissionId: 2,
    //         parentId: 1,
    //         name: '用户管理',
    //         path: '/super/user',
    //         redirect: null,
    //         component: '/super/user/index',
    //         status: 0,
    //         meta: {
    //           icon: 'el-icon-user',
    //           title: '用户管理'
    //         },
    //         createTime: '2020-12-08 21:25:54',
    //         updateTime: '2020-12-08 21:25:54',
    //         children: []
    //       },
    //       {
    //         permissionId: 3,
    //         parentId: 1,
    //         name: '角色管理',
    //         path: '/super/role',
    //         redirect: null,
    //         component: '/super/role/index',
    //         status: 0,
    //         meta: {
    //           icon: 'el-icon-s-custom',
    //           title: '角色管理'
    //         },
    //         createTime: '2020-12-08 21:30:23',
    //         updateTime: '2020-12-08 21:30:23',
    //         children: []
    //       },
    //       {
    //         permissionId: 4,
    //         parentId: 1,
    //         name: '菜单管理',
    //         path: '/super/menu',
    //         redirect: null,
    //         component: '/super/menu/index',
    //         status: 0,
    //         meta: {
    //           icon: 'el-icon-s-order',
    //           title: '菜单管理'
    //         },
    //         createTime: '2020-12-08 21:27:36',
    //         updateTime: '2020-12-08 21:27:36',
    //         children: []
    //       },
    //       {
    //         permissionId: 5,
    //         parentId: 1,
    //         name: '地域管理',
    //         path: '/super/area',
    //         redirect: null,
    //         component: '/super/area/index',
    //         status: 0,
    //         meta: {
    //           icon: 'el-icon-setting',
    //           title: '地域管理'
    //         },
    //         createTime: '2020-12-08 21:30:22',
    //         updateTime: '2020-12-08 21:30:22',
    //         children: []
    //       }
    //     ]
    //   },
    //   {
    //     permissionId: 999,
    //     parentId: 0,
    //     name: '个人信息',
    //     path: '/userinfo',
    //     redirect: null,
    //     component: '/userinfo/UserInfo',
    //     status: 0,
    //     meta: {
    //       icon: 'el-icon-user-solid',
    //       title: '个人信息'
    //     },
    //     createTime: '2020-12-08 21:30:22',
    //     updateTime: '2020-12-08 21:30:22',
    //     children: []
    //   }
    // ]
  }
});

Mock.mock('/museum-role/user/logout', 'post', {
  code: 200,
  message: '成功退出登陆',
  data: null
});

Mock.mock(RegExp('/museum-role/user/pageUserCondition' + '.*'), 'post', {
  code: 200,
  message: '获取用户列表',
  data: {
    total: 3,
    userList: [
      {
        userId: 14,
        userName: 'rw',
        realName: '省级人员',
        userStatus: 0,
        userSex: '女',
        areaName: '大同县',
        userPassword: '123456',
        userDesc: '但行好事,莫问前程',
        userPhone: '13603527760',
        userEmail: '13603527760',
        isDeleted: 0,
        createTime: '2020-12-02 18:00:17',
        updateTime: '2020-12-28 20:26:42',
        userWork: '开发人',
        userRole: {
          roleId: 2,
          roleName: '人员一'
        },
        areaNumber: 113
      },
      {
        userId: 15,
        userName: 'lb',
        realName: '省级人员',
        userStatus: 0,
        userSex: '男',
        areaName: '大同县',
        userPassword: '123456',
        userDesc: '但行好事,莫问前程',
        userPhone: '13603527760',
        userEmail: '13603527760',
        isDeleted: 0,
        createTime: '2020-12-28 11:28:11',
        updateTime: '2020-12-28 20:37:56',
        userWork: '开发人',
        userRole: {
          roleId: 2,
          roleName: '人员一'
        },
        areaNumber: 113
      },
      {
        userId: 43,
        userName: 'lb2',
        realName: 'string',
        userStatus: 0,
        userSex: 'string',
        areaName: '大同县',
        userPassword: '123',
        userDesc: 'string',
        userPhone: 'string',
        userEmail: 'string',
        isDeleted: 0,
        createTime: '2021-01-04 12:06:21',
        updateTime: '2021-01-04 12:06:21',
        userWork: 'string',
        userRole: {
          roleId: 200,
          roleName: '默认角色'
        },
        areaNumber: 113
      }
    ]
  }
});

Mock.mock('/user/addUser', 'post', {
  code: 200,
  message: '添加用户成功',
  data: null
});

Mock.mock('/museum-role/user/updateUser', 'put', {
  code: 200,
  message: '修改用户成功',
  data: null
});

Mock.mock(RegExp('/museum-role/user/deleteUser' + '.*'), 'delete', {
  code: 200,
  message: '删除用户成功',
  data: null
});
